Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite confirmation modals #1985

Merged
merged 75 commits into from
Feb 26, 2024
Merged

Conversation

niklasmohrin
Copy link
Member

@niklasmohrin niklasmohrin commented Jul 17, 2023

Closes #1851

Our modals have been bugging me for a while now and I believe the number of times I announced that I would rewrite them is just out of finger range. I am not sure how exactly it will look in the end, but I want it to be less Django magic and more browser native. My first vision here uses a custom web component at the use-site. This allows the logic of the modal to be together with the opening button. Furthermore, everything about the modal is contained in one HTML tag.

In my current plan, there won't be multiple users of one modal anymore, but instead multiple copies of the same template (specified by the custom web component). This will keep HTML size similar to what we had before, but increase DOM size significantly on sites with many modals (for example lists with deletable entries). We will have to see the effect this has on performance, I would believe that modern browsers should be able to handle this, but you never know. If it turns out to be slow, I would divert to trying to implement some kind of reference-modal component for sharing DOM nodes.

Thoughts?

Copy link
Member

@richardebeling richardebeling left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good! I like the declarative way to defining modals. The whole ElementInternals API is new to me, I can't really tell if the code is canonical, but it seems reasonable to me. It would still be nice to have frontend tests for that -- maybe one for a modal that can be directly submitted and one for semester deletion with the input validation?

evap/static/scss/components/_confirmation-modal.scss Outdated Show resolved Hide resolved
@richardebeling
Copy link
Member

(when converting new modals, it might make sense to do a separate commit for each modal so that reviewing becomes easier -- moved code is always hard to review)

@niklasmohrin niklasmohrin changed the title Rewrite modals Rewrite confirmation modals Jan 8, 2024
@niklasmohrin
Copy link
Member Author

I decided to leave the couple of contact modals as they are for now, because this PR is already huge

@niklasmohrin niklasmohrin marked this pull request as ready for review January 8, 2024 19:20
evap/grades/templates/grades_course_view.html Outdated Show resolved Hide resolved
evap/grades/templates/grades_course_view.html Outdated Show resolved Hide resolved
evap/static/ts/src/confirmation-modal.ts Show resolved Hide resolved
evap/staff/templates/staff_semester_view.html Show resolved Hide resolved
evap/staff/templates/staff_semester_view.html Show resolved Hide resolved
evap/staff/templates/staff_semester_view.html Outdated Show resolved Hide resolved
evap/grades/templates/grades_course_view.html Outdated Show resolved Hide resolved
Copy link
Member

@janno42 janno42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Please change placing to a central position
  • The focus should probably not be on the close button. Maybe on "Cancel"? Or in case of an additional form field on that field?

evap/evaluation/templates/confirmation_modal_template.html Outdated Show resolved Hide resolved
evap/contributor/templates/contributor_index.html Outdated Show resolved Hide resolved
evap/staff/templates/staff_questionnaire_index_list.html Outdated Show resolved Hide resolved
evap/staff/templates/staff_semester_view.html Outdated Show resolved Hide resolved
evap/staff/templates/staff_semester_view.html Outdated Show resolved Hide resolved
evap/staff/templates/staff_semester_view.html Show resolved Hide resolved
evap/staff/templates/staff_user_form.html Outdated Show resolved Hide resolved
Copy link
Member

@richardebeling richardebeling left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code is looking good

(Haven't tested. There is a chance that I may not spot errors in HTML changes.)

evap/grades/templates/grades_course_view.html Outdated Show resolved Hide resolved
evap/grades/templates/grades_course_view.html Show resolved Hide resolved
evap/staff/templates/staff_semester_view.html Outdated Show resolved Hide resolved
More realistic alternative to `current`

Add custom elements scaffold

looks right, doesn't open

found a way to use import, but not have icons modal texts displayed before script is loaded

fix usage of custom elements prototype before it was loaded

make it open the modal

dont know

some progess with native dialogs

make it look somewhat like bootstrap

progress?

make animations work

implement confirmation logic

ough, now the slots inherit values from the .card-header bar

Use `:defined` instead of `.loaded` class

more modals and fix blocktrans

Allow putting extra stuff under `confirmation-modal`

more modals

format

more modals
Copy link
Member

@richardebeling richardebeling left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code is nice, all modals work for me except for the delegation modal

evap/contributor/templates/contributor_index.html Outdated Show resolved Hide resolved
evap/staff/templates/staff_semester_view.html Outdated Show resolved Hide resolved
evap/staff/templates/staff_semester_view.html Show resolved Hide resolved
Copy link
Member

@richardebeling richardebeling left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! We can merge if/when remaining discussions are resolved.

@niklasmohrin
Copy link
Member Author

niklasmohrin commented Feb 26, 2024

Should I try to make a handful of useful commits out of this (not today), or should we just squash it?

@richardebeling
Copy link
Member

I'm fine with just squashing

Copy link
Collaborator

@Kakadus Kakadus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tick tack...

@niklasmohrin niklasmohrin merged commit 04015c9 into e-valuation:main Feb 26, 2024
11 of 12 checks passed
@niklasmohrin niklasmohrin deleted the rewrite-modals branch February 26, 2024 20:02
@richardebeling
Copy link
Member

Should we create a follow-up issue for the contact modal and the delegate preparation modal?

@niklasmohrin
Copy link
Member Author

Sounds good!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Update the modal logic
4 participants